///////////////////////////////////////////////////////////////////////////////////////////////////
// Illusion Ray Development Kit (IDK)           Copyright (c) 2010 ( dimitriy.martynenko@gmail.com )
///////////////////////////////////////////////////////////////////////////////////////////////////
// Created : 2010-05-22
// Updated : ...
// Licence : NEW BSD
// Info	   : IDK Engine
///////////////////////////////////////////////////////////////////////////////////////////////////
#pragma once
/*-------------------------------------------------------------------------
| TSceneModel:
| ------------
| TSceneModel
---------------------------------------------------------------------------*/
class TSceneModel : public TObject, virtual public IDK::ISceneModel
{
	IDKClass;
private:
	String mName;
	ref<IDK::IMesh> mMesh;
	ref<IDK::IMaterial> mMaterial;
public:
	TSceneModel(const String& name) : mName(name)
	{
	}

	virtual const String& GetName(void) const
	{
		return mName;
	}

	virtual void Rendered(IDK::IRenderState& /* rndState*/)
	{
	}

	virtual bool Render(IDK::IRenderState& rndState)
	{
		if(mMesh != NullPtr && mMaterial != NullPtr)
		{
			/*
			if(!rndState->GetIgnoredOpperation(IDK::IRenderState::IgnoredOpperation::UsingMaterials))
			{
				mMaterial->Draw(rndState);
			}
			*/
			mMaterial->Render(rndState);
			if(mMesh->Render(rndState)) //could mesh not diplayed then display dummy
			{
				//TODO: need draw dummy model?
			}
		}
		return true;
	}

	virtual void SetMaterial(ref<IDK::IMaterial> material)
	{
		mMaterial = material;
	}

	virtual void SetMesh(ref<IDK::IMesh> mesh)
	{
		mMesh = mesh;
	}
};

typedef ref<TSceneModel> SceneModel;